import moment from 'moment';
import 'moment/locale/zh-cn';
import qs from 'qs';
import axios from 'axios';
import throttle from 'lodash/throttle';
import debounce from 'lodash/debounce';
moment.locale('zh-cn');

//  get query string object
export const getQueryStringObject = () => {
   return qs.parse(window.location.href.split('?')[1]);
}

export const isWechat = () => window.navigator.userAgent.toLowerCase().includes('micromessenger');

export const trackEvent = eventId => {
   axios.post(
      `${APP_CONFIG.appServer}/common/review/userEventStatistics/submit`, 
      { reviewJoinupId: 1, eventId }, 
      { headers: { 'Authorization': localStorage.apiToken }
   }).then(res => {});
}

export const _ = {
   throttle,
   debounce,
};